from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):

    DB_HOST: str
    DB_PORT: int
    DB_USER: str
    DB_PASS: str
    DB_NAME: str

    @property
    def database_url_psycopg(self):
        # postgresql+psycopg://postgres:postgres@localhost:5432/books_library
        login = f"postgresql+psycopg://{self.DB_USER}:{self.DB_PASS}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}"
        return login

    model_config = SettingsConfigDict(env_file="../.env")
    SQLALCHEMY_DATABASE_URI = database_url_psycopg


settings = Settings()
